#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 200005
#define mod 998244353
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
const int INF=1e9;
int qpow(int a,int b){
	int res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;b>>=1;
	}
	return res;
}
/*
int fac[N],ifac[N];
int C(int n,int m){
	if(n<m||n<0||m<0) return 0;
	return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
void init(){
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=fac[i-1]*i%mod;
	ifac[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-2;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}*/
int T,n,m,L,V,num,cnt,sum[N];
int d[N],v[N],a[N],pd[N],c[N],now,mx[N];
int p[N];
pii lim[N];
struct node{int pos,id,ty;}b[N];
int cmp(node a,node b){return a.pos>b.pos||(a.pos==b.pos&&a.ty>b.ty);}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--){
		cin>>n>>m>>L>>V;num=0;cnt=0;
		for(int i=1;i<=n;i++) cin>>d[i]>>v[i]>>a[i],b[++cnt]={d[i],i,0},pd[i]=0;
		for(int i=1;i<=m;i++) cin>>p[i],b[++cnt]={p[i],i,1},mx[i]=0;
		sort(b+1,b+cnt+1,cmp);now=0;int ans=0;
		for(int i=1;i<=cnt;i++){
			if(b[i].ty==1) c[++now]=b[i].pos;
			else{
				int x=b[i].id;
				if(!now) continue;
				if(a[x]>=0){
					if(v[x]*v[x]+2*a[x]*(c[1]-d[x])>V*V){
						pd[x]=1;ans++;
						int l=1,r=now,res=0;
						while(l<=r){
							int mid=(l+r)>>1;
							if(v[x]*v[x]+2*a[x]*(c[mid]-d[x])>V*V) res=mid,l=mid+1;
							else r=mid-1;
						}
						num++;lim[num].fi=1;lim[num].se=res;
					//	cout<<1<<"+"<<res<<endl;
					} 
				}else{
					if(v[x]*v[x]<-2*a[x]*(c[now]-d[x])) continue;
					if(v[x]*v[x]+2*a[x]*(c[now]-d[x])>V*V){
						pd[x]=1;ans++;
						int l=1,r=now,res=0;
						while(l<=r){
							int mid=(l+r)>>1;
							if(v[x]*v[x]<-2*a[x]*(c[mid]-d[x])) l=mid+1;
							else if(v[x]*v[x]+2*a[x]*(c[mid]-d[x])>V*V) r=mid-1,res=mid;
							else l=mid+1;
						}
						num++;lim[num].fi=res;lim[num].se=now;
					//	cout<<res<<"+"<<now<<endl;
					}
				}
			}
		}
		for(int i=1;i<=m;i++) sum[i]=0;
		for(int i=1;i<=num;i++) mx[lim[i].se]=max(mx[lim[i].se],lim[i].fi);
		int tot=0;
		for(int i=1;i<=m;i++){
			if(mx[i]==0) sum[i]=sum[i-1];
			else{
				if(sum[i-1]==sum[mx[i]-1]) sum[i]=sum[i-1]+1,tot++;
				else sum[i]=sum[i-1];
			}
		}
		cout<<ans<<" "<<m-tot<<endl;
	}
	return 0;
}